#[doc = "Register `PERI_PMC31` reader"]
pub struct R(crate::R<PERI_PMC31_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PERI_PMC31_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<PERI_PMC31_SPEC>> for R {
    fn from(reader: crate::R<PERI_PMC31_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Report flag when the HPM2 original code word exceeds the upper threshold.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_UP_WARNING_A {
    #[doc = "0: The value does not exceed the upper threshold."]
    NOT_EXCEED = 0,
    #[doc = "1: The value exceeds the upper threshold."]
    EXCEED = 1,
}
impl From<HPM2_UP_WARNING_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_UP_WARNING_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_up_warning` reader - Report flag when the HPM2 original code word exceeds the upper threshold."]
pub struct HPM2_UP_WARNING_R(crate::FieldReader<bool, HPM2_UP_WARNING_A>);
impl HPM2_UP_WARNING_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_UP_WARNING_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_UP_WARNING_A {
        match self.bits {
            false => HPM2_UP_WARNING_A::NOT_EXCEED,
            true => HPM2_UP_WARNING_A::EXCEED,
        }
    }
    #[doc = "Checks if the value of the field is `NOT_EXCEED`"]
    #[inline(always)]
    pub fn is_not_exceed(&self) -> bool {
        **self == HPM2_UP_WARNING_A::NOT_EXCEED
    }
    #[doc = "Checks if the value of the field is `EXCEED`"]
    #[inline(always)]
    pub fn is_exceed(&self) -> bool {
        **self == HPM2_UP_WARNING_A::EXCEED
    }
}
impl core::ops::Deref for HPM2_UP_WARNING_R {
    type Target = crate::FieldReader<bool, HPM2_UP_WARNING_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Report flag when the HPM2 original code word is lower than the lower threshold.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_LOW_WARNING_A {
    #[doc = "0: The value is not lower than the lower threshold."]
    NOT_LOWER = 0,
    #[doc = "1: The value is lower than the lower threshold."]
    LOWER = 1,
}
impl From<HPM2_LOW_WARNING_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_LOW_WARNING_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_low_warning` reader - Report flag when the HPM2 original code word is lower than the lower threshold."]
pub struct HPM2_LOW_WARNING_R(crate::FieldReader<bool, HPM2_LOW_WARNING_A>);
impl HPM2_LOW_WARNING_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_LOW_WARNING_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_LOW_WARNING_A {
        match self.bits {
            false => HPM2_LOW_WARNING_A::NOT_LOWER,
            true => HPM2_LOW_WARNING_A::LOWER,
        }
    }
    #[doc = "Checks if the value of the field is `NOT_LOWER`"]
    #[inline(always)]
    pub fn is_not_lower(&self) -> bool {
        **self == HPM2_LOW_WARNING_A::NOT_LOWER
    }
    #[doc = "Checks if the value of the field is `LOWER`"]
    #[inline(always)]
    pub fn is_lower(&self) -> bool {
        **self == HPM2_LOW_WARNING_A::LOWER
    }
}
impl core::ops::Deref for HPM2_LOW_WARNING_R {
    type Target = crate::FieldReader<bool, HPM2_LOW_WARNING_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_pc_record1` reader - Reported value of the HPM2 original code word (last historical value)."]
pub struct HPM2_PC_RECORD1_R(crate::FieldReader<u16, u16>);
impl HPM2_PC_RECORD1_R {
    pub(crate) fn new(bits: u16) -> Self {
        HPM2_PC_RECORD1_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for HPM2_PC_RECORD1_R {
    type Target = crate::FieldReader<u16, u16>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "HPM2 output validity indicator.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_PC_VALID_A {
    #[doc = "0: the last read value of \\[hpm2_pc_record0\\]."]
    LAST_VALUE = 0,
    #[doc = "1: the current read value of \\[hpm2_pc_record0\\]."]
    CURRENT_VALUE = 1,
}
impl From<HPM2_PC_VALID_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_PC_VALID_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_pc_valid` reader - HPM2 output validity indicator."]
pub struct HPM2_PC_VALID_R(crate::FieldReader<bool, HPM2_PC_VALID_A>);
impl HPM2_PC_VALID_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_PC_VALID_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_PC_VALID_A {
        match self.bits {
            false => HPM2_PC_VALID_A::LAST_VALUE,
            true => HPM2_PC_VALID_A::CURRENT_VALUE,
        }
    }
    #[doc = "Checks if the value of the field is `LAST_VALUE`"]
    #[inline(always)]
    pub fn is_last_value(&self) -> bool {
        **self == HPM2_PC_VALID_A::LAST_VALUE
    }
    #[doc = "Checks if the value of the field is `CURRENT_VALUE`"]
    #[inline(always)]
    pub fn is_current_value(&self) -> bool {
        **self == HPM2_PC_VALID_A::CURRENT_VALUE
    }
}
impl core::ops::Deref for HPM2_PC_VALID_R {
    type Target = crate::FieldReader<bool, HPM2_PC_VALID_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_pc_record0` reader - Reported value of the HPM2 original code word (current value)."]
pub struct HPM2_PC_RECORD0_R(crate::FieldReader<u16, u16>);
impl HPM2_PC_RECORD0_R {
    pub(crate) fn new(bits: u16) -> Self {
        HPM2_PC_RECORD0_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for HPM2_PC_RECORD0_R {
    type Target = crate::FieldReader<u16, u16>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl R {
    #[doc = "Bit 25 - Report flag when the HPM2 original code word exceeds the upper threshold."]
    #[inline(always)]
    pub fn hpm2_up_warning(&self) -> HPM2_UP_WARNING_R {
        HPM2_UP_WARNING_R::new(((self.bits >> 25) & 0x01) != 0)
    }
    #[doc = "Bit 24 - Report flag when the HPM2 original code word is lower than the lower threshold."]
    #[inline(always)]
    pub fn hpm2_low_warning(&self) -> HPM2_LOW_WARNING_R {
        HPM2_LOW_WARNING_R::new(((self.bits >> 24) & 0x01) != 0)
    }
    #[doc = "Bits 12:21 - Reported value of the HPM2 original code word (last historical value)."]
    #[inline(always)]
    pub fn hpm2_pc_record1(&self) -> HPM2_PC_RECORD1_R {
        HPM2_PC_RECORD1_R::new(((self.bits >> 12) & 0x03ff) as u16)
    }
    #[doc = "Bit 10 - HPM2 output validity indicator."]
    #[inline(always)]
    pub fn hpm2_pc_valid(&self) -> HPM2_PC_VALID_R {
        HPM2_PC_VALID_R::new(((self.bits >> 10) & 0x01) != 0)
    }
    #[doc = "Bits 0:9 - Reported value of the HPM2 original code word (current value)."]
    #[inline(always)]
    pub fn hpm2_pc_record0(&self) -> HPM2_PC_RECORD0_R {
        HPM2_PC_RECORD0_R::new((self.bits & 0x03ff) as u16)
    }
}
#[doc = "PERI_PMC31 is the HPM2 original code word and alarm information register.\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [peri_pmc31](index.html) module"]
pub struct PERI_PMC31_SPEC;
impl crate::RegisterSpec for PERI_PMC31_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [peri_pmc31::R](R) reader structure"]
impl crate::Readable for PERI_PMC31_SPEC {
    type Reader = R;
}
#[doc = "`reset()` method sets PERI_PMC31 to value 0"]
impl crate::Resettable for PERI_PMC31_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
